package test923;

import java.util.Scanner;

public class fourth {
    public static void main(String[] args) {
        int[] arr = new int[5];
        Scanner scanner = new Scanner(System.in);
        int n;
        int myMin = 999;
        System.out.println("please enter 5 number:");
        for(int i = 0;i<arr.length;i++ )
        {
            n = scanner.nextInt();
            arr[i] = n;
        }
        for(int i = 0;i<arr.length;i++ )
        {
            if(arr[i] < myMin)
            {
                myMin = arr[i];
            }
            System.out.print(" arr[" + i + "] = " + arr[i]);
        }
//        sort
//        for(int i = 0;i<arr.length - 1; i++)
//        {
//            for(int j = 0;j < arr.length - i -1; j++)
//            {
//                if(arr[j] > arr[j+1])
//                {
//                    int temp = arr[j+1];
//                    arr[j+1] = arr[j];
//                    arr[j] = temp;
//                }
//            }
//        }
        for (int i = 0; i < arr.length - 1; i++) {
            int minIndex = i;

            // Find the minimum element in the remaining unsorted array
            for (int j = i + 1; j < arr.length; j++) {
                if (arr[j] < arr[minIndex]) {
                    minIndex = j;
                }
            }

            // Swap the found minimum element with the first element
            int temp = arr[minIndex];
            arr[minIndex] = arr[i];
            arr[i] = temp;
        }


        System.out.println();
        for(int i = 0;i<arr.length;i++ )
        {
            if(arr[i] < myMin)
            {
                myMin = arr[i];
            }
            System.out.print(" arr[" + i + "] = " + arr[i]);
        }
//        System.out.println();
//        System.out.println("myMin is: "+ myMin);
    }
}
